<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>HTML/JS工具-{$Think.config.title} </title>
	<link rel="stylesheet" href="__PUBLIC__/Css/labs.css" />
</head>
<body>
{:W('Module/header')}
<div id="Html_Container">
<h2 class="sitetip">贴入要格式化或压缩的HTML或JS代码：</h2>

<textarea  name="content" id="content" placeholder="请粘贴要格式化或者整理的HTML或者JS代码"
	class="tarea"></textarea>
	<div class="subbtn">
 <select name="tabsize" class="btn btn-success" class="formatSelect" id="tabsize">
                  <option value="1">
                    		制表符缩进
                  </option>
                  <option value="2" selected="selected">
                    2个空格缩进
                  </option>
                  <option value="4">
                    4个空格缩进
                  </option>
                  <option value="8">
                    8个空格缩进
                  </option>
                </select>
	<input type="button" onclick="return do_js_beautify();" value="美化代码" id="beautify" class="btn btn-success" /> 
	<input type="button" onclick="pack_js(0);" value="普通压缩" class="btn btn-success" /> 
	<input type="button" onclick="pack_js(1);" value="加密压缩" class="btn btn-success" />
</div>
	<h2 class="sitetip">转换后的HTML或者JS代码代码：</h2>
<textarea id="packer" placeholder="格式化或者整理后可以右键复制这里的代码"
	class="tarea">
</textarea>
</div>

{:W('Module/footer')}
      <script type="text/javascript" src="__PUBLIC__/Js/htmljsFormat/base2-p.js">
      </script>
      <script type="text/javascript" src="__PUBLIC__/Js/htmljsFormat/packer-p.js">
      </script>
      <script type="text/javascript" src="__PUBLIC__/Js/htmljsFormat/beautify.js">
      </script>
      <script type="text/javascript" src="__PUBLIC__/Js/htmljsFormat/beautify-tests.js">
      </script>
      <script type="text/javascript" src="__PUBLIC__/Js/htmljsFormat/HTML-Beautify.js">
      </script>
      <script type="text/javascript">
        function do_js_beautify() {
          document.getElementById('beautify').disabled = true;
          js_source = document.getElementById('content').value.replace(/^\s+/, '');
          tabsize = document.getElementById('tabsize').value;
          tabchar = ' ';
          if (tabsize == 1) {
            tabchar = '\t';
          }
          if (js_source && js_source.charAt(0) === '<') {
            document.getElementById('packer').value = style_html(js_source, tabsize, tabchar, 80);
          } else {
            document.getElementById('packer').value = js_beautify(js_source, tabsize, tabchar);
          }
          document.getElementById('beautify').disabled = false;
          return false;
        }
        function pack_js(base64) {
          var input = document.getElementById('content').value;
          var packer = new Packer;
          if (base64) {
            var output = packer.pack(input, 1, 0);
          } else {
            var output = packer.pack(input, 0, 0);
          }
          document.getElementById('packer').value = output;
        }

      </script>
      
</body>
</html>
